﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Npgsql;
using System.Configuration;

namespace IonosphereViewer
{
    public partial class WebForm2 : System.Web.UI.Page
    {
        const string SqlDetail =
            @"SELECT 
              id,
              measure_date,
              seans,
              nr1,
              nr2,
              measure_type,
              date_modify,
              user_id
            FROM 
              public.headerall";            

        protected void Page_Load(object sender, EventArgs e)
        {
            this.Error += new EventHandler(_Default_Error);
            NpgsqlConnection conn = new NpgsqlConnection(WebFormDefault.constring);
            conn.Open();
            try
            {
                NpgsqlCommand dccard1 = new NpgsqlCommand(SqlDetail, conn);

                NpgsqlDataReader er1 = dccard1.ExecuteReader();
                try
                {
                    er1.Read();
                    //LabelOwner.Text = er1["holder"].ToString();
                    //LabelCardNo.Text = er1["card_no"].ToString();
                    //LabelGroupNo.Text = er1["group_no"].ToString();
                    //LabelSumma.Text = String.Format("{0:C}", er1["summa"]);
                    //LabelGroupSumma.Text = String.Format("{0:C}", er1["groupsumma"]);
                }
                finally
                {
                    er1.Close();
                }
                DataGridInfo.DataSource = er1;
                DataGridInfo.DataBind();
            }
            finally
            {
                conn.Close();
            }
        }

        protected void ButtonStat_Click(object sender, EventArgs e)
        {
            string theInfo = "";
            theInfo += String.Format("<Li> Is the client AOL? {0}", Request.Browser.AOL);
            theInfo += String.Format("<Li> Does the client support ActiveX? {0}", Request.Browser.ActiveXControls);
            theInfo += String.Format("<Li> Is the client a Beta? {0}", Request.Browser.Beta);
            theInfo += String.Format("<Li> Does the client support Java Applets? {0}", Request.Browser.JavaApplets);
            theInfo += String.Format("<Li> Does the client support Cookies? {0}", Request.Browser.Cookies);
            theInfo += String.Format("<Li> Does the client support VBScript? {0}", Request.Browser.VBScript);
            LabelInfo.Text = theInfo;
            Response.Write("Была получена информация о браузере клиента.");
        }

        void _Default_Error(object sender, EventArgs e)
        {
            Response.Clear();
            Response.Write("Page Error!<br />");
            Response.Write(string.Format("Error: <b>{0}</b>", Server.GetLastError().Message));
            Server.ClearError();
        }
    }
}
